/**
 * https://leetcode.cn/problems/min-cost-climbing-stairs/submissions/562501293/
 * 746. 使用最小花费爬楼梯
 * medium 陈贝纯 2024.09.07
 * 经典线性
 */

class Solution {
public:
    int minCostClimbingStairs(vector<int>& cost) {
        int dp[1001]={0};
        dp[0]=cost[0];
        dp[1]=cost[1];
        for(int i=2;i<cost.size();++i){
            dp[i]=min(dp[i-1],dp[i-2])+cost[i];
        }
        return min(dp[cost.size()-1],dp[cost.size()-2]);
    }
};